import allure
from page_base.page_base import Base
# from page_element.el_A3mall import *
from page_element.roncoo_login import *
from utils.timer import sleep
import logging



class RoncooLogin(Base):
    """登录页面"""
    def roncoo_login(self):
        # 打开
        self.open_url(url)

        self.maximize_window()
        with allure.step(f"输入用户名:"):
            self.send_keys(login_pe.login_username, 'admin')
        with allure.step(f"输入密码:"):
            self.send_keys(login_pe.login_pwd,'123456')
        # 强制等待输入验证码
        sleep(10)
        with allure.step("点击登录按钮"):
            self.click(login_pe.login_btn)
        #隐式等待---系统菜单
        self.driver.implicitly_wait(10)
        with allure.step('验证登录成功'):
            dy = self.text(login_pe.login_dy_text)
            assert '系统菜单' in dy, f"断言失败(验证失败): 期望包含'系统菜单'，实际得到'{dy}'"


        # 断言
        # with allure.step("验证登录"):
        #     if '登录成功' in casename:
        #         dy = self.text(home_pe.home_person_text)
        #         logging.info(f"预期结果：{expected}，实际结果: {dy}")
        #         assert expected in dy, f"断言失败(验证失败): 期望包含'{expected}'，实际得到'{dy}'"
        #         logging.info(f"验证成功,{casename}")
        #     else:
        #         dy = self.text(login_pe.login_dy_text)
        #         logging.info(f"预期结果：{expected}，实际结果: {dy}")
        #         assert expected == dy, f"断言失败(验证失败): 期望等于'{expected}'，实际得到'{dy}'"
        #         logging.info(f"验证成功,{casename}")
